package cn.bugDance.domain.strategy.model.entity;

import cn.bugDance.types.common.Constants;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class RuleConfigEntity {
    private Long strategyId;

    private Integer awardId;

    /**
     * 0. 策略级别
     * 1. 策略奖品级别
     */
    private Integer ruleType;

    private String ruleModel;

    private String config;

    private String ruleDesc;

    public Map<Integer, List<Integer>> ruleConfigSplit(){
        if(null == config) return null;
        String[] var1s = config.split(Constants.SPACE);
        Map<Integer, List<Integer>> map = new ConcurrentHashMap<>();

        for(String var1 : var1s){
            String[] var2s = var1.split(Constants.COLON);
            Integer level = Integer.valueOf(var2s[0]);
            String[] var3s = var2s[1].split(Constants.SPLIT);
            List<Integer> awardIds = new ArrayList<>();
            for(String var3 : var3s){
                Integer awardId = Integer.valueOf(var3);
                awardIds.add(awardId);
            }
            map.put(level, awardIds);
        }

        return map;
    }
}
